import VueRouter from 'vue-router'
import home from './components/tabbar/Home.vue'
import member from './components/tabbar/Member.vue'
import shopcar from './components/tabbar/ShopCar.vue'
import search from './components/tabbar/Search.vue'
import newslist from './components/news/NewsList.vue'
import newsinfo from './components/news/NewsInfo.vue'
import photolist from './components/photos/PhotoList.vue'
import photoinfo from './components/photos/PhotoInfo.vue'
import goodslist from './components/goods/GoodsList.vue'
import goodsinfo from './components/goods/GoodsInfo.vue'
import login from './components/users/Login.vue'
import reg from './components/users/Reg.vue'

var router = new VueRouter({
    routes: [
      { path: "/", redirect: "/home" },
      { path: "/home", component: home },
      { path: "/member", component: member },
      { path: "/shopcar", component: shopcar },
      { path: "/search", component: search },
      { path: "/home/newslist", component: newslist },
      { path: "/home/newsinfo", component: newsinfo },
      { path: "/home/photolist", component: photolist },
      { path: "/home/photoinfo", component: photoinfo },
      { path: "/home/goodslist", component: goodslist },
      { path: "/home/goodsinfo", component: goodsinfo },
      { path: "/member/login", component: login },
      { path: "/member/reg", component: reg }
    ],
    linkActiveClass: 'mui-active',   //设置路由高亮类，默认为'router-link-active'
    scrollBehavior (to, from, savedPosition) {    // 切换到新路由时，页面滚到顶部，或者是保持原先的滚动位置
      if (savedPosition) {  // 通过浏览器的 前进/后退 按钮触发
        return savedPosition
      } else {
        return { x: 0, y: 0 }
      }
    }
  })

  export default router